
#include "GameTileLayer.h"
#include "TitleScene.h"

USING_NS_CC;

bool GameTileLayer::init() {
	if (!CCLayer::init()) {
		return false;
	}
	_tileMap = CCTMXTiledMap::create("map1.tmx");


	CCObject *pObject = NULL;
	CCARRAY_FOREACH(_tileMap->getChildren(), pObject)
	{
		CCTMXLayer *child = (CCTMXLayer*) pObject;
		child->getTexture()->setAliasTexParameters();
	}

	this->addChild(_tileMap, -6);

	CCMenuItemFont* backBut = CCMenuItemFont::create("返回", this, menu_selector(GameTileLayer::backToTotleScene));
	backBut->setPosition(ccp(backBut->getContentSize().width/2, CCDirector::sharedDirector()->getVisibleSize().height-backBut->getContentSize().height/2));
	ccColor3B color = {255, 0, 0};
	backBut->setColor(color);
	CCMenu* menu = CCMenu::create(backBut, NULL);
	menu->setPosition(CCPointZero);

	this->addChild(menu);

	return true;
}

void GameTileLayer::backToTotleScene()
{
	CCDirector::sharedDirector()->replaceScene(TitleScene::create());
}
